import $ from '../common';
Page({
  data: {
    info:[],
    page:1,
    tip:'上滑加载更多'
  },
  // $.navigateTo('/schedule/index')

  onLoad(e) {
    this.setData({
      zonecode:wx.getStorageSync('addresscode')||''
    })
    this.getlist()
  },
  onShow() {},
  goschedule(){
    $.navigateTo('/schedule/index')
  },
  goalready(e){
    const {item}=e.currentTarget.dataset
   $.navigateTo(`/course/alreadycourse?group_uuid=${item.uuid}&student_uuid=${item.student_uuid}&type=course`)
  },
  getlist(){
    const{info,page,zonecode}=this.data
    $.get('/campus/student/groups',{
      limit:20,
      zonecode,
      page,
    },res=>{
      if(res.groups.length<20){
        this.data.tip='已经到底了'
      }else{
        this.data.tip='上滑加载更多'
      }
      this.data.page++
      this.setData({
        page:this.data.page,
        tip:this.data.tip,
        info:[...info,...res.groups]
      })
    })
  },
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },
})